const express = require('express');
const StudentController = require('../controllers/StudentController');
const { createDebounceMiddleware } = require('../middleware/debounce');
const { authenticateToken, requireTeacher } = require('../middleware/auth');

const router = express.Router();

// 学生管理路由
router.get('/', authenticateToken, requireTeacher, StudentController.getStudents);
router.post('/', authenticateToken, requireTeacher, StudentController.createStudent);
router.get('/:id', authenticateToken, requireTeacher, StudentController.getStudentDetail);
router.put('/:id', authenticateToken, requireTeacher, StudentController.updateStudent);
router.delete('/:id', authenticateToken, requireTeacher, StudentController.deleteStudent);

// 学生课时相关路由
router.get('/:id/lessons', authenticateToken, requireTeacher, StudentController.getStudentLessons);
router.post('/:id/lessons', authenticateToken, requireTeacher, createDebounceMiddleware(1000), StudentController.addStudentLesson);
router.put('/:id/lessons/:lesson_id', authenticateToken, requireTeacher, createDebounceMiddleware(1000), StudentController.updateStudentLesson);
router.delete('/:id/lessons/:lesson_id', authenticateToken, requireTeacher, createDebounceMiddleware(500), StudentController.deleteStudentLesson);
router.put('/:id/lessons', authenticateToken, requireTeacher, createDebounceMiddleware(1000), StudentController.updateStudentLessons);

module.exports = router; 